package com.ivan.eduservice.controller;

import com.ivan.commonutils.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Ivan
 * @Description 登录的controller
 * @Date 2020/8/6 15:52
 */
@Api("登录")
@RestController
@RequestMapping("/eduservice/user")
@CrossOrigin//允许跨域
public class EduLoginController {

    /**
     * @Author Ivan
     * @Description 登录的方法
     * @Date 2020/8/6 15:53
     * @Param
     * @return
     */
    @ApiOperation(value = "用户登录")
    @PostMapping("/login")
    public CommonResult login(){
        return CommonResult.success().data("token", "admin");
    }

    /**
     * @Author Ivan
     * @Description 获取用户信息
     * @Date 2020/8/6 15:53
     * @Param
     * @return
     */
    @ApiOperation(value = "获取用户信息")
    @GetMapping("/info")
    public CommonResult info(){
        return CommonResult.success().data("roles", "[admin]")
                                     .data("name", "Ivan Admin")
                                     .data("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
    }

    /**
     * @Author Ivan
     * @Description 登录的方法
     * @Date 2020/8/6 15:53
     * @Param
     * @return
     */
    @ApiOperation(value = "退出登录")
    @PostMapping("/logout")
    public CommonResult logout(){
        return CommonResult.success().message("success");
    }
}
